package fr.unice.polytech.chord.core.messages.asynchronous;

import fr.unice.polytech.chord.core.ChordNode;
import fr.unice.polytech.chord.core.Key;
import fr.unice.polytech.chord.core.responses.asynchronous.EntryResponseMessage;
import fr.unice.polytech.chord.core.responses.asynchronous.AsynchronousResponseMessage;

/**
 * Retrieves a given entry or <code>null</code> if not found.
 * 
 * @author Anthony Parisy
 * @author Laurent Pellegrino
 * @author Marc Valdener
 * 
 * @version 10/28/2009
 */
@SuppressWarnings("serial")
public class GetEntryMessage extends AsynchronousMessage {

	private Key keyToUse;

	/**
	 * Constructor.
	 * 
	 * @param key
	 *            the key associated to the entry we are looking up.
	 */
	public GetEntryMessage(Key key) {
		this.keyToUse = key;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public AsynchronousResponseMessage handle(ChordNode node) {
		return new EntryResponseMessage(node.getEntry(this.keyToUse));
	}
}
